home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu546.dms / pu546.adf / Planets / Julday.c < prev    next >
C/C++ Source or Header  |  1992-09-23  |  867b  |  27 lines

  1. /*******************************************************************************
  2. ** Compute the Julian Date from a given local date.                           **
  3. ** Sorry, Bob. Your routine didn't seem to work correctly.                    **
  4. *******************************************************************************/
  5. #include <stdio.h>
  6. #include <math.h>
  7.  
  8. double julday(day,month,year,hour)
  9. int    day,month,year;
  10. double hour;
  11.    {
  12.    double a;
  13.    long   to_long();
  14.    int    b;
  15.  
  16.    a = 10000.*year+100.*month+(double)day;
  17.    if(month<=2) {
  18.       month += 12; year -= 1;
  19.       }
  20.    if(a <= 15821004.1)
  21.       b = -2 + (int)to_long((year+4716)/4.) - 1179;
  22.    else
  23.       b = (int)(to_long(year/400.) - to_long(year/100.) + to_long(year/4.));
  24.    a  = 365.*year-679004.+2400000.5;
  25.    return(a+(double)b+(double)to_long(30.6001*(month+1))+(double)day+hour/24.);
  26.    }
  27.